import Vue from 'vue'
import App from './App.vue'
import router from './router'
import 'element-ui/lib/theme-chalk/index.css'


// 代码高亮
import hljs from 'highlight.js'
import 'highlight.js/styles/monokai-sublime.css' //样式文件
Vue.directive('highlight', function(el) {
    let blocks = el.querySelectorAll('pre code');
    setTimeout(() => {
        blocks.forEach((block) => {
            hljs.highlightBlock(block)
        })
    }, 200)
})

import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
Vue.use(mavonEditor)

import marked from 'marked'
Vue.prototype.$marked = marked

Vue.config.productionTip = false

import axios from 'axios'
Vue.prototype.$axios = axios
Vue.prototype.HOST = 'https://www.fatgirl.top:39089'

import md5 from 'js-md5'
Vue.prototype.$md5 = md5


    // 插件Clipboard实现点击复制
import Clipboard from 'clipboard';
Vue.prototype.Clipboard = Clipboard;

router.beforeEach((to, from, next) => {
    if (to.meta.requireLogin) {
        if (localStorage.getItem("token")) {
            next();
        } else {
            next('/Login?hint=true');
        }
    } else {
        next();
    }
});


new Vue({ router, render: h => h(App), }).$mount('#app')